﻿Imports System.Data.SqlClient
Imports System.Web
Imports System.Data.OleDb
Public Class Login
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

        Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\CruisesDB.accdb;Persist Security Info=True"
        Dim dt As New DataTable()
        Dim conn As New OleDbConnection(connectionString)
        If TextBox1.Text <> "" And TextBox2.Text <> "" Then

            'SELECT        Uname, UPassword FROM            Users WHERE        (Uname = '1') AND (UPassword = '2')

            Dim sql As String = "select * from Users where Uname='" & TextBox1.Text & "' and Upassword='" & TextBox2.Text & "'"



            Dim cmd As New OleDbCommand(sql, conn)
            If conn.State = Data.ConnectionState.Closed Then conn.Open()
            Dim dr As OleDbDataReader = cmd.ExecuteReader
            If dr.HasRows Then
                dr.Read()
                Session("UserId") = dr.Item(0)
                Session("username") = TextBox1.Text
                Response.Redirect("HomeUser.aspx")
            Else
                Label1.Visible = True
            End If
        End If
    End Sub
End Class